﻿using System;
using System.Collections.Generic;
using System.Data;
using eTMS.Controllers.MonHocService;
namespace eTMS.Controllers{
public class MonHocController : MonHocControllerBase{
	public MonHocController()
		: base()
	{
	}
    public bool SaveMonHocTable()
    {
        bool result = true;
        foreach (DataRow row in Table.Rows)
        {
            MonHocObject = MapDataRowToObject(row);
            if (MonHocObject.MonHoc_ID == 0)
            {
                result &= AddNew();
            }
        }
        return result;
    }
    public static MonHocEntity FindMonHoc(int MonHoc_ID)
    {
        MonHocEntity oResult = ListMonHocStatic.Find(delegate(MonHocEntity oFind)
        {
            bool result = true;
            result &= oFind.MonHoc_ID.Equals(MonHoc_ID);
            return result;
        });
        return oResult;
    }
    public void LoadMonHocByListBoMon(List<int> LsBoMon_ID)
    {
        MonHocServiceClient monHocServiceClient=new MonHocServiceClient();
        Table = monHocServiceClient.SelectAllDSFilter("BoMon_ID IN(" + string.Join(",", LsBoMon_ID.ConvertAll<string>(Convert.ToString).ToArray()) + ")").Tables[0];
        AddIndexToTable();
        Commons.Common.AddCheckedToTable(Table);
    }
    public void ResetTable()
    {
        Table = new DataTable();
        Table.Columns.Add("MonHoc_ID", typeof(int));
        Table.Columns.Add("MaMonHoc", typeof(string));
        Table.Columns.Add("TenMonHoc", typeof(string));
        Table.Columns.Add("BoMon_ID", typeof(int));
        Table.Columns.Add("SoHocPhan", typeof(int));
        Table.Columns.Add("SoHocPhanHocPhi", typeof(int));
        Table.Columns.Add("SoTietHoc", typeof(int));
        Table.Columns.Add("MoTa", typeof(string));
    }
}
}
